<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>Hexo博客每天自动生成每日早报文章 | 月月博客</title><meta name="author" content="月月"><meta name="copyright" content="月月"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="前言 本文将详细介绍如何在Hexo博客中实现自动生成每日早报文章功能效果。  固定单页面访问 需要使用到 ALAPI 的 每日60秒早报 接口，可免费调用注册登录后在 个人管理 &#x3D;&gt; 个人中心 &#x3D;&gt; 获取token  静态页面访问 如果只想生成一个固定的静态页面访问，可以直接使用以下代码，替换自己的token将代码保存到一个html文件内，存放博客主目录source文件夹即可  &amp;lt">
<meta property="og:type" content="article">
<meta property="og:title" content="Hexo博客每天自动生成每日早报文章">
<meta property="og:url" content="https://blog.tuxiw.cn/pages/%E4%B8%BB%E9%A2%98%E9%AD%94%E6%94%B9/Hexo2.html">
<meta property="og:site_name" content="月月博客">
<meta property="og:description" content="前言 本文将详细介绍如何在Hexo博客中实现自动生成每日早报文章功能效果。  固定单页面访问 需要使用到 ALAPI 的 每日60秒早报 接口，可免费调用注册登录后在 个人管理 &#x3D;&gt; 个人中心 &#x3D;&gt; 获取token  静态页面访问 如果只想生成一个固定的静态页面访问，可以直接使用以下代码，替换自己的token将代码保存到一个html文件内，存放博客主目录source文件夹即可  &amp;lt">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://api.r10086.com/%E6%A8%B1%E9%81%93%E9%9A%8F%E6%9C%BA%E5%9B%BE%E7%89%87api%E6%8E%A5%E5%8F%A3.php?%E5%9B%BE%E7%89%87%E7%B3%BB%E5%88%97=%E5%8A%A8%E6%BC%AB%E7%BB%BC%E5%90%889">
<meta property="article:published_time" content="2025-05-08T02:41:44.000Z">
<meta property="article:modified_time" content="2025-05-08T03:14:01.110Z">
<meta property="article:author" content="月月">
<meta property="article:tag" content="主题">
<meta property="article:tag" content="魔改">
<meta property="article:tag" content="美化">
<meta property="article:tag" content="Hexo">
<meta property="article:tag" content="Web">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://api.r10086.com/%E6%A8%B1%E9%81%93%E9%9A%8F%E6%9C%BA%E5%9B%BE%E7%89%87api%E6%8E%A5%E5%8F%A3.php?%E5%9B%BE%E7%89%87%E7%B3%BB%E5%88%97=%E5%8A%A8%E6%BC%AB%E7%BB%BC%E5%90%889"><script type="application/ld+json">{
  "@context": "https://schema.org",
  "@type": "BlogPosting",
  "headline": "Hexo博客每天自动生成每日早报文章",
  "url": "https://blog.tuxiw.cn/pages/%E4%B8%BB%E9%A2%98%E9%AD%94%E6%94%B9/Hexo2.html",
  "image": "https://api.r10086.com/樱道随机图片api接口.php?图片系列=动漫综合9",
  "datePublished": "2025-05-08T02:41:44.000Z",
  "dateModified": "2025-05-08T03:14:01.110Z",
  "author": [
    {
      "@type": "Person",
      "name": "月月",
      "url": "https://blog.tuxiw.cn/"
    }
  ]
}</script><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://blog.tuxiw.cn/pages/%E4%B8%BB%E9%A2%98%E9%AD%94%E6%94%B9/Hexo2.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><script>
    (() => {
      
    const saveToLocal = {
      set: (key, value, ttl) => {
        if (!ttl) return
        const expiry = Date.now() + ttl * 86400000
        localStorage.setItem(key, JSON.stringify({ value, expiry }))
      },
      get: key => {
        const itemStr = localStorage.getItem(key)
        if (!itemStr) return undefined
        const { value, expiry } = JSON.parse(itemStr)
        if (Date.now() > expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return value
      }
    }

    window.btf = {
      saveToLocal,
      getScript: (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        Object.entries(attr).forEach(([key, val]) => script.setAttribute(key, val))
        script.onload = script.onreadystatechange = () => {
          if (!script.readyState || /loaded|complete/.test(script.readyState)) resolve()
        }
        script.onerror = reject
        document.head.appendChild(script)
      }),
      getCSS: (url, id) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onload = link.onreadystatechange = () => {
          if (!link.readyState || /loaded|complete/.test(link.readyState)) resolve()
        }
        link.onerror = reject
        document.head.appendChild(link)
      }),
      addGlobalFn: (key, fn, name = false, parent = window) => {
        if (!false && key.startsWith('pjax')) return
        const globalFn = parent.globalFn || {}
        globalFn[key] = globalFn[key] || {}
        globalFn[key][name || Object.keys(globalFn[key]).length] = fn
        parent.globalFn = globalFn
      }
    }
  
      
      const activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      const activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }

      btf.activateDarkMode = activateDarkMode
      btf.activateLightMode = activateLightMode

      const theme = saveToLocal.get('theme')
    
          theme === 'dark' ? activateDarkMode() : theme === 'light' ? activateLightMode() : null
        
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        document.documentElement.classList.toggle('hide-aside', asideStatus === 'hide')
      }
    
      
    const detectApple = () => {
      if (/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)) {
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
  
    })()
  </script><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false,"highlightFullpage":false,"highlightMacStyle":false},
  copy: {
    success: '复制成功',
    error: '复制失败',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'null',
  Snackbar: {"chs_to_cht":"已切换为繁体中文","cht_to_chs":"已切换为简体中文","day_to_night":"已切换为深色模式","night_to_day":"已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#1f1f1f","position":"top-right"},
  infinitegrid: {
    js: 'https://cdn.jsdelivr.net/npm/@egjs/infinitegrid/dist/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyloadPlugin: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Hexo博客每天自动生成每日早报文章',
  isHighlightShrink: false,
  isToc: true,
  pageType: 'post'
}</script><link rel="stylesheet" href="/css/floatbox.css"><link rel="stylesheet" href="/css/footer.css"><link rel="stylesheet" href="/css/transpancy.css"><link rel="stylesheet" href="/css/custom.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/zhheo/JS-Heo@main/rightmenu/rightmenu.css"><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/zhheo/JS-Heo@main/mainColor/heoMainColor.css"><script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/zyoushuo/Blog@latest/hexo/css/loading_style_1.css" ><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/zyoushuo/Blog@latest/hexo/css/loading_style_2.css" ><!-- hexo injector head_end start --><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiper.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiperstyle.css" media="print" onload="this.media='all'"><!-- hexo injector head_end end --><meta name="generator" content="Hexo 7.3.0"><link rel="alternate" href="/atom.xml" title="月月博客" type="application/atom+xml">
</head><body><div class="float-box left top"></div><div class="float-box left bottom"></div><div class="float-box right top"></div><div class="float-box right bottom"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img text-center"><img src="/img/loading.gif" data-original="/img/tx/tx1.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data text-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">10</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">20</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">7</div></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><span class="site-page group"><i class="fa-fw fas fa-book"></i><span> 文章</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></li></ul></div><div class="menus_item"><span class="site-page group"><i class="fa-fw fas fa-paper-plane"></i><span> 导航</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="https://nav.tuxiw.cn/"><i class="fa-fw fas fa-sign-in"></i><span> 站内</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://nav.shiguang666.eu.org/"><i class="fa-fw fas fa-sign-out"></i><span> 站外</span></a></li></ul></div><div class="menus_item"><span class="site-page group"><i class="fa-fw fa-solid fa-flask"></i><span> 实验室</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/news"><i class="fa-fw fa fa-calendar"></i><span> 每日早报</span></a></li><li><a class="site-page child" href="/random"><i class="fa-fw fas fa-random"></i><span> 随机文章</span></a></li><li><a class="site-page child" href="/atom.xml"><i class="fa-fw fas fa-rss"></i><span> RSS订阅</span></a></li></ul></div><div class="menus_item"><span class="site-page group"><i class="fa-fw fa-solid fa-user-group"></i><span> 友链</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/flink/"><i class="fa-fw fa-solid fa-user-tie"></i><span> 本站友链</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://www.travellings.cn/go.html"><i class="fa-fw fa fa-subway"></i><span> 随机开往</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://travel.moe/go.html?travel=on"><i class="fa-fw fa fa-taxi"></i><span> 异次元之旅</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/comment/"><i class="fa-fw fas fa-comments"></i><span> 留言</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url(https://api.r10086.com/樱道随机图片api接口.php?图片系列=动漫综合9);"><nav id="nav"><span id="blog-info"><a class="nav-site-title" href="/"><img class="site-icon" src="/img/loading.gif" data-original="/img/tx/tx1.jpg" alt="Logo"><span class="site-name">月月博客</span></a><a class="nav-page-title" href="/"><span class="site-name">Hexo博客每天自动生成每日早报文章</span></a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><span class="site-page group"><i class="fa-fw fas fa-book"></i><span> 文章</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></li></ul></div><div class="menus_item"><span class="site-page group"><i class="fa-fw fas fa-paper-plane"></i><span> 导航</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="https://nav.tuxiw.cn/"><i class="fa-fw fas fa-sign-in"></i><span> 站内</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://nav.shiguang666.eu.org/"><i class="fa-fw fas fa-sign-out"></i><span> 站外</span></a></li></ul></div><div class="menus_item"><span class="site-page group"><i class="fa-fw fa-solid fa-flask"></i><span> 实验室</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/news"><i class="fa-fw fa fa-calendar"></i><span> 每日早报</span></a></li><li><a class="site-page child" href="/random"><i class="fa-fw fas fa-random"></i><span> 随机文章</span></a></li><li><a class="site-page child" href="/atom.xml"><i class="fa-fw fas fa-rss"></i><span> RSS订阅</span></a></li></ul></div><div class="menus_item"><span class="site-page group"><i class="fa-fw fa-solid fa-user-group"></i><span> 友链</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/flink/"><i class="fa-fw fa-solid fa-user-tie"></i><span> 本站友链</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://www.travellings.cn/go.html"><i class="fa-fw fa fa-subway"></i><span> 随机开往</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://travel.moe/go.html?travel=on"><i class="fa-fw fa fa-taxi"></i><span> 异次元之旅</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/comment/"><i class="fa-fw fas fa-comments"></i><span> 留言</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><span class="site-page"><i class="fas fa-bars fa-fw"></i></span></div></div></nav><div id="post-info"><h1 class="post-title">Hexo博客每天自动生成每日早报文章</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2025-05-08T02:41:44.000Z" title="发表于 2025-05-08 10:41:44">2025-05-08</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2025-05-08T03:14:01.110Z" title="更新于 2025-05-08 11:14:01">2025-05-08</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E4%B8%BB%E9%A2%98%E9%AD%94%E6%94%B9/">主题魔改</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span id="" data-flag-title=""><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">浏览量:</span><span id="twikoo_visitors"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="container post-content" id="article-container"><h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><blockquote>
<p>本文将详细介绍如何在<code>Hexo</code>博客中实现<code>自动生成每日早报文章</code>功能效果。</p>
</blockquote>
<h2 id="固定单页面访问"><a href="#固定单页面访问" class="headerlink" title="固定单页面访问"></a>固定单页面访问</h2><blockquote>
<p>需要使用到 <a target="_blank" rel="noopener" href="https://www.alapi.cn/">ALAPI</a> 的 <a target="_blank" rel="noopener" href="https://www.alapi.cn/api/67/introduction">每日60秒早报</a> 接口，可免费调用<br>注册登录后在 <code>个人管理 =&gt; 个人中心 =&gt; 获取token</code></p>
</blockquote>
<h3 id="静态页面访问"><a href="#静态页面访问" class="headerlink" title="静态页面访问"></a>静态页面访问</h3><blockquote>
<p>如果只想生成一个固定的静态页面访问，可以直接使用以下代码，替换自己的<code>token</code><br>将代码保存到一个<code>html</code>文件内，存放博客主目录<code>source</code>文件夹即可</p>
</blockquote>
<figure class="highlight html"><table><tr><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">&quot;en&quot;</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">&quot;UTF-8&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">http-equiv</span>=<span class="string">&quot;X-UA-Compatible&quot;</span> <span class="attr">content</span>=<span class="string">&quot;IE=edge&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">&quot;viewport&quot;</span> <span class="attr">content</span>=<span class="string">&quot;width=device-width, initial-scale=1.0&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>每日早报<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span> <span class="attr">style</span>=<span class="string">&quot;text-align: center;&quot;</span>&gt;</span> <span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">&quot;https://v3.alapi.cn/api/zaobao?token=xxxxxxxxxxx&amp;format=image&quot;</span></span></span><br><span class="line"><span class="tag">            <span class="attr">alt</span>=<span class="string">&quot;每日早报&quot;</span> <span class="attr">width</span>=<span class="string">&quot;100%&quot;</span>&gt;</span> <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>
<h3 id="page页面"><a href="#page页面" class="headerlink" title="page页面"></a>page页面</h3><blockquote>
<p>创建一个<code>page</code>页面</p>
</blockquote>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">hexo new page &quot;daily-news-detail&quot;</span><br></pre></td></tr></table></figure>
<blockquote>
<p>然后修改<code>source\daily-news-detail\index.md</code>文件，打开源码模式，粘贴以下代码，替换<code>token</code>内容</p>
</blockquote>
<figure class="highlight markdown"><table><tr><td class="code"><pre><span class="line">---</span><br><span class="line"><span class="section">title: 每日早报</span></span><br><span class="line"><span class="section">---</span></span><br><span class="line"></span><br><span class="line">&lt;!DOCTYPE html&gt;</span><br><span class="line"><span class="language-xml"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">&quot;en&quot;</span>&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="language-xml"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span></span><br><span class="line"><span class="code">    &lt;meta charset=&quot;UTF-8&quot;&gt;</span></span><br><span class="line"><span class="code">    &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;</span></span><br><span class="line"><span class="code">    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;</span></span><br><span class="line"><span class="code">    &lt;title&gt;每日早报&lt;/title&gt;</span></span><br><span class="line"><span class="code">&lt;/head&gt;</span></span><br><span class="line"><span class="code">&lt;body&gt;</span></span><br><span class="line"><span class="code">    &lt;div style=&quot;text-align: center;&quot;&gt; &lt;img src=&quot;https://v3.alapi.cn/api/zaobao?token=xxxxxxxxxxx&amp;format=image&quot;</span></span><br><span class="line"><span class="code">            alt=&quot;每日早报&quot; width=&quot;100%&quot;&gt; &lt;/div&gt;</span></span><br><span class="line"><span class="code">&lt;/body&gt;</span></span><br><span class="line"><span class="code"></span></span><br><span class="line"><span class="language-xml"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span></span><br></pre></td></tr></table></figure>
<blockquote>
<p>直接访问刚才生成的 daily-news-detail目录即可</p>
</blockquote>
<h2 id="每天生成新的文章"><a href="#每天生成新的文章" class="headerlink" title="每天生成新的文章"></a>每天生成新的文章</h2><blockquote>
<p>由于 <code>Front Matter</code> 是静态的，不能直接在 <code>Markdown</code> 文件中动态引用 <code>JSON</code> 文件的内容。<br>所以如果想仅生成一篇文章每天<code>动态加载</code>文章标题及封面也需要使用下面的方法。</p>
</blockquote>
<blockquote>
<p>在 主题目录<code>scripts</code> 文件夹下创建一个新的<code>JavaScript</code>文件，例如 <code>fetch-daily-news.js</code>，<br>我使用的主题是 <code>Butterfly</code>，具体目录为<code> themes\butterfly\scripts</code>，替换代码中的<code>token</code></p>
</blockquote>
<figure class="highlight javascript"><table><tr><td class="code"><pre><span class="line"><span class="keyword">const</span> axios = <span class="built_in">require</span>(<span class="string">&#x27;axios&#x27;</span>);</span><br><span class="line"><span class="keyword">const</span> fs = <span class="built_in">require</span>(<span class="string">&#x27;fs&#x27;</span>);</span><br><span class="line"><span class="keyword">const</span> path = <span class="built_in">require</span>(<span class="string">&#x27;path&#x27;</span>);</span><br><span class="line"><span class="keyword">const</span> moment = <span class="built_in">require</span>(<span class="string">&#x27;moment&#x27;</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 设置 moment 的语言环境为中文</span></span><br><span class="line">moment.<span class="title function_">locale</span>(<span class="string">&#x27;zh-cn&#x27;</span>);</span><br><span class="line"></span><br><span class="line">hexo.<span class="title function_">on</span>(<span class="string">&#x27;ready&#x27;</span>, <span class="function">() =&gt;</span> &#123;</span><br><span class="line">    <span class="keyword">const</span> apiUrl = <span class="string">&#x27;https://v3.alapi.cn/api/zaobao&#x27;</span>;</span><br><span class="line">    <span class="keyword">const</span> token = <span class="string">&#x27;xxxxxxxxxxx&#x27;</span>; <span class="comment">// 替换为你的token</span></span><br><span class="line"></span><br><span class="line">    axios.<span class="title function_">get</span>(apiUrl, &#123;</span><br><span class="line">        <span class="attr">params</span>: &#123;</span><br><span class="line">            <span class="attr">token</span>: token</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;)</span><br><span class="line">        .<span class="title function_">then</span>(<span class="function"><span class="params">response</span> =&gt;</span> &#123;</span><br><span class="line">            <span class="keyword">const</span> data = response.<span class="property">data</span>;</span><br><span class="line">            <span class="keyword">if</span> (data.<span class="property">code</span> === <span class="number">200</span>) &#123;</span><br><span class="line">                <span class="keyword">let</span> newsData = data.<span class="property">data</span>;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">                <span class="comment">// 执行历史数据 Start</span></span><br><span class="line"></span><br><span class="line">                <span class="comment">// const oldDataFileName = &quot;daily_news_2024-06-20.json&quot;  // 修改需要执行的数据文件名称</span></span><br><span class="line">                <span class="comment">// const oldDataPath = path.join(__dirname, &#x27;../../../source/_data/&#x27;+oldDataFileName);</span></span><br><span class="line">                <span class="comment">// console.log(&quot;Daily news oldDataPath is :&quot;,oldDataPath);</span></span><br><span class="line">                <span class="comment">// const oldData = JSON.parse(fs.readFileSync(oldDataPath, &#x27;utf8&#x27;));</span></span><br><span class="line">                <span class="comment">// newsData = oldData;</span></span><br><span class="line"></span><br><span class="line">                <span class="comment">// 执行历史数据 End</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">                <span class="comment">// 使用 newsData.date 转换为星期几</span></span><br><span class="line">                <span class="keyword">const</span> postDate = newsData.<span class="property">date</span>;</span><br><span class="line">                <span class="keyword">const</span> postDayOfWeek = <span class="title function_">moment</span>(postDate).<span class="title function_">format</span>(<span class="string">&#x27;dddd&#x27;</span>);</span><br><span class="line">            </span><br><span class="line">                <span class="keyword">const</span> filePath = path.<span class="title function_">join</span>(__dirname, <span class="string">&#x27;../../../source/_data/daily_news_&#x27;</span>+postDate+<span class="string">&#x27;.json&#x27;</span>);</span><br><span class="line">                <span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="string">&#x27;Daily news save data filePath is :&#x27;</span>, filePath);</span><br><span class="line"></span><br><span class="line">                <span class="comment">// 生成json文件</span></span><br><span class="line">                fs.<span class="title function_">writeFileSync</span>(filePath, <span class="title class_">JSON</span>.<span class="title function_">stringify</span>(newsData, <span class="literal">null</span>, <span class="number">2</span>));</span><br><span class="line">                </span><br><span class="line"></span><br><span class="line">                <span class="comment">// 生成 Markdown 文件</span></span><br><span class="line">                <span class="comment">// const postDayOfWeek = moment().format(&#x27;dddd&#x27;); // 获取中文的星期几</span></span><br><span class="line">                <span class="keyword">const</span> postTitle = <span class="string">`【每日早报】-<span class="subst">$&#123;postDate&#125;</span> - <span class="subst">$&#123;postDayOfWeek&#125;</span>`</span>;</span><br><span class="line">                <span class="keyword">const</span> postContent = <span class="string">`---</span></span><br><span class="line"><span class="string">title: <span class="subst">$&#123;postTitle&#125;</span></span></span><br><span class="line"><span class="string">date: <span class="subst">$&#123;postDate&#125;</span> 00:00:00</span></span><br><span class="line"><span class="string">tags:</span></span><br><span class="line"><span class="string">  - 每日早报</span></span><br><span class="line"><span class="string">categories:</span></span><br><span class="line"><span class="string">  - 每日早报</span></span><br><span class="line"><span class="string">series: 每日早报</span></span><br><span class="line"><span class="string">cover: <span class="subst">$&#123;newsData.head_image&#125;</span></span></span><br><span class="line"><span class="string">---</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">&lt;!DOCTYPE html&gt;</span></span><br><span class="line"><span class="string">&lt;html lang=&quot;en&quot;&gt;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">&lt;head&gt;</span></span><br><span class="line"><span class="string">    &lt;meta charset=&quot;UTF-8&quot;&gt;</span></span><br><span class="line"><span class="string">    &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;</span></span><br><span class="line"><span class="string">    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;</span></span><br><span class="line"><span class="string">    &lt;title&gt;每日早报&lt;/title&gt;</span></span><br><span class="line"><span class="string">&lt;/head&gt;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">&lt;body&gt;</span></span><br><span class="line"><span class="string">    &lt;div style=&quot;text-align: center;&quot;&gt; &lt;img src=&quot;`</span>+newsData.<span class="property">image</span>+<span class="string">`&quot;</span></span><br><span class="line"><span class="string">            alt=&quot;每日早报&quot; width=&quot;100%&quot;&gt; &lt;/div&gt;</span></span><br><span class="line"><span class="string">&lt;/body&gt;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">&lt;/html&gt;`</span>;</span><br><span class="line"></span><br><span class="line">                <span class="keyword">const</span> postFilePath = path.<span class="title function_">join</span>(__dirname, <span class="string">&#x27;../../../source/_posts&#x27;</span>, <span class="string">`<span class="subst">$&#123;postTitle&#125;</span>.md`</span>);</span><br><span class="line">                fs.<span class="title function_">writeFileSync</span>(postFilePath, postContent);</span><br><span class="line"></span><br><span class="line">                </span><br><span class="line">                <span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="string">&#x27;Daily news post generated successfully:&#x27;</span>, postFilePath);</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                <span class="variable language_">console</span>.<span class="title function_">error</span>(<span class="string">&#x27;Failed to fetch daily news:&#x27;</span>, data.<span class="property">msg</span>);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;)</span><br><span class="line">        .<span class="title function_">catch</span>(<span class="function"><span class="params">error</span> =&gt;</span> &#123;</span><br><span class="line">            <span class="variable language_">console</span>.<span class="title function_">error</span>(<span class="string">&#x27;Error fetching daily news:&#x27;</span>, error);</span><br><span class="line">        &#125;);</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>
<blockquote>
<p>此处需要 用到两个插件 <code>axios</code> 和 <code>moment</code></p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">#安装 axios</span><br><span class="line">npm install axios</span><br><span class="line">#安装 moment</span><br><span class="line">npm install moment</span><br></pre></td></tr></table></figure></blockquote>
<blockquote>
<p>调用接口生成的数据会保存在博客主目录 <code>/source/_data/daily_news_xxxx-xx-xx.json</code>，如果没有<code>_data</code>目录可以手动创建一下，防止因找不到目录文件保存失败。<br>注意根据实际情况调整文件的存放路径</p>
</blockquote>
<figure class="highlight javascript"><table><tr><td class="code"><pre><span class="line"><span class="keyword">const</span> postFilePath = path.<span class="title function_">join</span>(__dirname, <span class="string">&#x27;../../../source/_posts&#x27;</span>, <span class="string">`<span class="subst">$&#123;postTitle&#125;</span>.md`</span>);</span><br></pre></td></tr></table></figure>
<blockquote>
<p>文章的标题，目录，标签，系列文章分类等也可自行调整</p>
</blockquote>
<figure class="highlight markdown"><table><tr><td class="code"><pre><span class="line">tags:</span><br><span class="line"><span class="bullet">  -</span> 每日早报</span><br><span class="line">categories:</span><br><span class="line"><span class="bullet">  -</span> 每日早报</span><br><span class="line">series: 每日早报</span><br></pre></td></tr></table></figure>
<blockquote>
<p>为了确保 <code>Hexo</code> 能够正确加载 <code>_data</code> 目录下的数据文件。可以在 <code>_config.yml</code> 文件中添加以下配置，确保 <code>_data</code> 目录被正确加载</p>
</blockquote>
<figure class="highlight markdown"><table><tr><td class="code"><pre><span class="line">data<span class="emphasis">_dir: source/_</span>data</span><br></pre></td></tr></table></figure>
<blockquote>
<p>如果你只想生成一篇文章，然后把这篇文章置顶，那只需要将生成的<code>markdown</code>文件名固定就可以了</p>
</blockquote>
<figure class="highlight javascript"><table><tr><td class="code"><pre><span class="line"><span class="keyword">const</span> postFilePath = path.<span class="title function_">join</span>(__dirname, <span class="string">&#x27;../../../source/_posts&#x27;</span>, <span class="string">`每日早报.md`</span>);</span><br></pre></td></tr></table></figure>
<blockquote>
<p>这样每次执行 <code>hexo g</code> 时重新生成的文件会覆盖原来的文件</p>
</blockquote>
<h2 id="插件"><a href="#插件" class="headerlink" title="插件"></a>插件</h2><h3 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h3><blockquote>
<p>要在你的 Hexo 项目目录中安装此插件</p>
</blockquote>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">npm install hexo-daily-news --save</span><br></pre></td></tr></table></figure>
<h3 id="配置"><a href="#配置" class="headerlink" title="配置"></a>配置</h3><blockquote>
<p>将以下配置添加到你的 _config.yml 文件中<br>如果当天多次执行 <code>hexo g</code> ，最好<code>禁用</code>插件，否则会频繁消耗api调用额度，目前免费账户每日请求上限为<code>100条</code></p>
</blockquote>
<figure class="highlight yaml"><table><tr><td class="code"><pre><span class="line"><span class="attr">hexo-daily-news:</span></span><br><span class="line">  <span class="attr">enable:</span> <span class="literal">true</span></span><br><span class="line">  <span class="attr">apiUrl:</span> <span class="string">&#x27;https://v3.alapi.cn/api/zaobao&#x27;</span></span><br><span class="line">  <span class="attr">token:</span> <span class="string">&#x27;your-api-token&#x27;</span></span><br></pre></td></tr></table></figure>
<h3 id="使用"><a href="#使用" class="headerlink" title="使用"></a>使用</h3><blockquote>
<p>安装并配置好插件后，运行以下命令生成每日新闻文章</p>
</blockquote>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">hexo generate / hexo g</span><br></pre></td></tr></table></figure>
<blockquote>
<p>插件将从指定的 API 获取最新的新闻数据，将其保存为 source&#x2F;_data 目录中的 JSON 文件，并在 source&#x2F;_posts 目录中生成一个新的 Markdown 文章。</p>
</blockquote>
<h2 id="参考"><a href="#参考" class="headerlink" title="参考"></a>参考</h2><p><a target="_blank" rel="noopener" href="https://www.cnblogs.com/an-shiguang/p/18269047">時光</a><br><a target="_blank" rel="noopener" href="https://github.com/Shiguang-coding/hexo-daily-news/blob/main/README.md">hexo-daily-news</a></p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="https://blog.tuxiw.cn">月月</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="https://blog.tuxiw.cn/pages/%E4%B8%BB%E9%A2%98%E9%AD%94%E6%94%B9/Hexo2.html">https://blog.tuxiw.cn/pages/%E4%B8%BB%E9%A2%98%E9%AD%94%E6%94%B9/Hexo2.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来源 <a href="https://blog.tuxiw.cn" target="_blank">月月博客</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E4%B8%BB%E9%A2%98/">主题</a><a class="post-meta__tags" href="/tags/%E9%AD%94%E6%94%B9/">魔改</a><a class="post-meta__tags" href="/tags/%E7%BE%8E%E5%8C%96/">美化</a><a class="post-meta__tags" href="/tags/Hexo/">Hexo</a><a class="post-meta__tags" href="/tags/Web/">Web</a></div><div class="post-share"><div class="social-share" data-image="https://api.r10086.com/樱道随机图片api接口.php?图片系列=动漫综合9" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><a class="pagination-related" href="/pages/%E4%B8%BB%E9%A2%98%E9%AD%94%E6%94%B9/Hexo.html" title="Hexo博客实现随机文章功能"><img class="cover" src="/img/loading.gif" data-original="https://api.r10086.com/樱道随机图片api接口.php?图片系列=动漫综合11" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="info"><div class="info-1"><div class="info-item-1">上一篇</div><div class="info-item-2">Hexo博客实现随机文章功能</div></div><div class="info-2"><div class="info-item-1">前言 想要给博客增加一些趣味性？让读者可以随机浏览你的文章是个不错的选择。本文将详细介绍如何在Hexo博客中实现随机文章功能效果。  功能介绍 随机文章功能可以让访问者随机浏览博客中的任意一篇文章,这不仅能增加博客的趣味性,还能提高文章的曝光率,让一些早期的优质文章也有机会被读者发现。  实现步骤创建主题文件 首先在主题的layout目录下创建random.ejs文件  &lt;%// 获取所有文章const posts = site.posts.data;// 随机选择一篇文章const randomPost = posts[Math.floor(Math.random() * posts.length)];%&gt;&lt;script&gt;// 立即重定向到随机文章window.location.href = &#x27;&lt;%- url_for(randomPost.path) %&gt;&#x27;;&lt;/script&gt;&lt;noscript&gt;  &lt;div style=&quot;text-align: center; padding:...</div></div></div></a><a class="pagination-related" href="/pages/SSL/allinssl.html" title="allinssl提供免费SSL泛域名通配符SSL证书"><img class="cover" src="/img/loading.gif" data-original="https://cos.tuxiw.cn/blog/bg1.webp" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="info text-right"><div class="info-1"><div class="info-item-1">下一篇</div><div class="info-item-2">allinssl提供免费SSL泛域名通配符SSL证书</div></div><div class="info-2"><div class="info-item-1">前言 如今，SSL证书的在网站建设的重要性是不言而喻的，而SSL证书的有效期也在逐步的缩短，从过去的一年有效期变为了如今的90天，更有传闻表示，SSL证书的有效期还会在未来继续缩减。这时候一旦你的网站多了起来，更新网站的SSL证书这件事就会变得十分的麻烦，这时候有一个能够实现SSL证书自动申请和部署的的工具就显得尤为重要了。   注意：请先查看支持的 授权 API 当前面板支持宝塔面板,1Panel当前DNS支持阿里云,腾讯云  ALLinSSL背景：SSL 证书管理的痛点 SSL&#x2F;TLS 证书对于保障网站和在线服务的安全通信至关重要，是现代互联网不可或缺的一部分。然而，对于拥有多台服务器、多个域名或使用复杂云环境的用户来说，管理这些证书往往是一项繁琐且易出错的任务：  分散混乱: 证书散落在不同的服务器、云平台、CDN 或负载均衡器上，缺乏统一视图。 配置复杂: 手动申请、验证、配置和部署证书流程复杂，需要一定的技术背景，且容易出错。 续期难题: 证书有效期有限，忘记续期或续期操作失误可能导致服务中断和安全风险。 缺乏监控:...</div></div></div></a></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><a class="pagination-related" href="/pages/%E4%B8%BB%E9%A2%98%E9%AD%94%E6%94%B9/Hexo.html" title="Hexo博客实现随机文章功能"><img class="cover" src="/img/loading.gif" data-original="https://api.r10086.com/樱道随机图片api接口.php?图片系列=动漫综合11" alt="cover"><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-05-08</div><div class="info-item-2">Hexo博客实现随机文章功能</div></div><div class="info-2"><div class="info-item-1">前言 想要给博客增加一些趣味性？让读者可以随机浏览你的文章是个不错的选择。本文将详细介绍如何在Hexo博客中实现随机文章功能效果。  功能介绍 随机文章功能可以让访问者随机浏览博客中的任意一篇文章,这不仅能增加博客的趣味性,还能提高文章的曝光率,让一些早期的优质文章也有机会被读者发现。  实现步骤创建主题文件 首先在主题的layout目录下创建random.ejs文件  &lt;%// 获取所有文章const posts = site.posts.data;// 随机选择一篇文章const randomPost = posts[Math.floor(Math.random() * posts.length)];%&gt;&lt;script&gt;// 立即重定向到随机文章window.location.href = &#x27;&lt;%- url_for(randomPost.path) %&gt;&#x27;;&lt;/script&gt;&lt;noscript&gt;  &lt;div style=&quot;text-align: center; padding:...</div></div></div></a></div></div><hr class="custom-hr"/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div id="twikoo-wrap"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info text-center"><div class="avatar-img"><img src="/img/loading.gif" data-original="/img/tx/tx1.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info-name">月月</div><div class="author-info-description">欢迎来到月月的技术资源站</div><div class="site-data"><a href="/archives/"><div class="headline">文章</div><div class="length-num">10</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">20</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">7</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://gitee.com/fs529"><i class="fab fa-github"></i><span>前往 Gitee</span></a><div class="card-info-social-icons"><a class="social-icon" href="https://github.com/shenyu2806" target="_blank" title="Github"><i class="fab fa-github" style="color: #24292e;"></i></a><a class="social-icon" href="/tuzwsy@gmail.com" target="_blank" title="Email"><i class="fas fa-envelope" style="color: #4a7dbe;"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">欢迎来到月月的博客! <br> 主地址：<a href="https://blog.tuxiw.cn" style="color:#49b1f5">blog.tuxiw.cn</a><br> 备用地址：<a target="_blank" rel="noopener" href="https://blog-shenyun.pages.dev" style="color:#49b1f5">blog-shenyun.pages.dev</a></div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%89%8D%E8%A8%80"><span class="toc-number">1.</span> <span class="toc-text">前言</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%9B%BA%E5%AE%9A%E5%8D%95%E9%A1%B5%E9%9D%A2%E8%AE%BF%E9%97%AE"><span class="toc-number">2.</span> <span class="toc-text">固定单页面访问</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%9D%99%E6%80%81%E9%A1%B5%E9%9D%A2%E8%AE%BF%E9%97%AE"><span class="toc-number">2.1.</span> <span class="toc-text">静态页面访问</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#page%E9%A1%B5%E9%9D%A2"><span class="toc-number">2.2.</span> <span class="toc-text">page页面</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%AF%8F%E5%A4%A9%E7%94%9F%E6%88%90%E6%96%B0%E7%9A%84%E6%96%87%E7%AB%A0"><span class="toc-number">3.</span> <span class="toc-text">每天生成新的文章</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%8F%92%E4%BB%B6"><span class="toc-number">4.</span> <span class="toc-text">插件</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85"><span class="toc-number">4.1.</span> <span class="toc-text">安装</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE"><span class="toc-number">4.2.</span> <span class="toc-text">配置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8"><span class="toc-number">4.3.</span> <span class="toc-text">使用</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8F%82%E8%80%83"><span class="toc-number">5.</span> <span class="toc-text">参考</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/pages/%E7%BD%91%E7%AB%99/Website%20revenue.html" title="网站被收录情况"><img src="/img/loading.gif" data-original="https://cos.tuxiw.cn/blog/bg4.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="网站被收录情况"/></a><div class="content"><a class="title" href="/pages/%E7%BD%91%E7%AB%99/Website%20revenue.html" title="网站被收录情况">网站被收录情况</a><time datetime="2025-06-12T13:30:46.000Z" title="发表于 2025-06-12 21:30:46">2025-06-12</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/pages/SSL/FreeSSL.html" title="FreeSSL申请免费证书"><img src="/img/loading.gif" data-original="https://cos.tuxiw.cn/blog/bg3.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="FreeSSL申请免费证书"/></a><div class="content"><a class="title" href="/pages/SSL/FreeSSL.html" title="FreeSSL申请免费证书">FreeSSL申请免费证书</a><time datetime="2025-05-10T03:00:51.000Z" title="发表于 2025-05-10 11:00:51">2025-05-10</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/pages/SSL/allinssl.html" title="allinssl提供免费SSL泛域名通配符SSL证书"><img src="/img/loading.gif" data-original="https://cos.tuxiw.cn/blog/bg1.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="allinssl提供免费SSL泛域名通配符SSL证书"/></a><div class="content"><a class="title" href="/pages/SSL/allinssl.html" title="allinssl提供免费SSL泛域名通配符SSL证书">allinssl提供免费SSL泛域名通配符SSL证书</a><time datetime="2025-05-10T02:33:33.000Z" title="发表于 2025-05-10 10:33:33">2025-05-10</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/pages/%E4%B8%BB%E9%A2%98%E9%AD%94%E6%94%B9/Hexo2.html" title="Hexo博客每天自动生成每日早报文章"><img src="/img/loading.gif" data-original="https://api.r10086.com/樱道随机图片api接口.php?图片系列=动漫综合9" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Hexo博客每天自动生成每日早报文章"/></a><div class="content"><a class="title" href="/pages/%E4%B8%BB%E9%A2%98%E9%AD%94%E6%94%B9/Hexo2.html" title="Hexo博客每天自动生成每日早报文章">Hexo博客每天自动生成每日早报文章</a><time datetime="2025-05-08T02:41:44.000Z" title="发表于 2025-05-08 10:41:44">2025-05-08</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/pages/%E4%B8%BB%E9%A2%98%E9%AD%94%E6%94%B9/Hexo.html" title="Hexo博客实现随机文章功能"><img src="/img/loading.gif" data-original="https://api.r10086.com/樱道随机图片api接口.php?图片系列=动漫综合11" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Hexo博客实现随机文章功能"/></a><div class="content"><a class="title" href="/pages/%E4%B8%BB%E9%A2%98%E9%AD%94%E6%94%B9/Hexo.html" title="Hexo博客实现随机文章功能">Hexo博客实现随机文章功能</a><time datetime="2025-05-08T02:19:24.000Z" title="发表于 2025-05-08 10:19:24">2025-05-08</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer_button"><ul class="buttons"><li class="icon Email"><span class="bubble">Email</span><a href="mailto:tuzwsy@gmail.com"><i class="fa-solid fa-envelope"></i></a></li><li class="icon QQ"><span class="bubble">QQ</span><a href="tencent://Message/?Uin=758427981&amp;websiteName=q-zone.qq.com&amp;Menu=yes"><i class="fa-brands fa-qq"></i></a></li><li class="icon top"><span class="bubble">top</span><a href="#"><i class="fa-solid fa-angle-up"></i></a></li><li class="icon github"><span class="bubble">Github</span><a target="_blank" rel="noopener" href="https://github.com/shenyu2806"><i class="fab fa-github"></i></a></li><li class="icon CSDN"><span class="bubble">Gitee</span><a target="_blank" rel="noopener" href="https://gitee.com/fs529"><i class="fab fa-github"></i></a></li></ul></div><div id="Hsu-foot"><div class="footer-group"><h3 class="footer-title">直达</h3><div class="footer-links"><a class="footer-item" href="/" target="_blank">我的主页</a><a class="footer-item" href="/bb">个人动态</a><a class="footer-item" href="/random">随机文章</a></div></div><div class="footer-group"><h3 class="footer-title">分类</h3><div class="footer-links"><a class="footer-item" href="/categories/学习笔记/">学习笔记</a></div></div><div class="footer-group"><h3 class="footer-title">关于</h3><div class="footer-links"><a class="footer-item" href="/about">关于我</a><a class="footer-item" href="/archives">文章归档</a></div></div><div class="footer-group"><h3 class="footer-title">友链</h3><div class="footer-links"><a class="footer-item" href="/flink">在这里 ✨</a><a class="footer-item" href="mailto:tuzwsy@gmail.com">广告位招租啦</a></div></div><div class="footer-group"><h3 class="footer-title">协议</h3><div class="footer-links"><a class="footer-item" href="/privacy">隐私协议</a><a class="footer-item" href="/cc">版权协议</a></div></div></div><div id="footer-wrap"><div class="copyright">&copy;2019 - 2025  <i id="heartbeat" class="fa fas fa-heartbeat"></i> 月月</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a><span class="footer-separator">|</span><span> <a target="_blank" rel="noopener" href="https://icp.gov.moe/?keyword=20248911">萌ICP备20248911号</a></span></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="日间和夜间模式切换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="share" type="button" title="分享链接" onclick="share()"><i class="fas fa-share-nodes"></i></button><a id="to_comment" href="#post-comment" title="前往评论"><i class="fas fa-comments"></i></a><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button><button id="go-down" type="button" title="直达底部" onclick="btf.scrollToDest(document.body.scrollHeight, 500)"><i class="fas fa-arrow-down"></i></button></div></div><div id="rightMenu"><div class="rightMenu-group rightMenu-small"><div class="rightMenu-item" id="menu-backward"><i class="fa-solid fa-arrow-left"></i></div><div class="rightMenu-item" id="menu-forward"><i class="fa-solid fa-arrow-right"></i></div><div class="rightMenu-item" id="menu-refresh"><i class="fa-solid fa-arrow-rotate-right"></i></div><div class="rightMenu-item" id="menu-home"><i class="fa-solid fa-house"></i></div></div><div class="rightMenu-group rightMenu-line"><a class="rightMenu-item" id="menu-radompage" href="/random"><i class="fa-solid fa-shoe-prints"></i><span>随便逛逛</span></a><div class="rightMenu-item" id="menu-share"><i class="fas fa-share-nodes"></i><span>分享链接</span></div></div></div><div id="rightmenu-mask" onclick="RemoveRightMenu()"></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><div class="js-pjax"><script>(() => {
  const isShuoshuo = GLOBAL_CONFIG_SITE.pageType === 'shuoshuo'
  const option = null

  const getCount = () => {
    const countELement = document.getElementById('twikoo-count')
    if(!countELement) return
    twikoo.getCommentsCount({
      envId: 'https://twikoo.tuxiw.cn/',
      region: '',
      urls: [window.location.pathname],
      includeReply: false
    }).then(res => {
      countELement.textContent = res[0].count
    }).catch(err => {
      console.error(err)
    })
  }

  const init = (el = document, path = location.pathname) => {
    twikoo.init({
      el: el.querySelector('#twikoo-wrap'),
      envId: 'https://twikoo.tuxiw.cn/',
      region: '',
      onCommentLoaded: () => {
        btf.loadLightbox(document.querySelectorAll('#twikoo .tk-content img:not(.tk-owo-emotion)'))
      },
      ...option,
      path: isShuoshuo ? path : (option && option.path) || path
    })

    

    isShuoshuo && (window.shuoshuoComment.destroyTwikoo = () => {
      if (el.children.length) {
        el.innerHTML = ''
        el.classList.add('no-comment')
      }
    })
  }

  const loadTwikoo = (el, path) => {
    if (typeof twikoo === 'object') setTimeout(() => init(el, path), 0)
    else btf.getScript('https://cdn.jsdelivr.net/npm/twikoo/dist/twikoo.all.min.js').then(() => init(el, path))
  }

  if (isShuoshuo) {
    'Twikoo' === 'Twikoo'
      ? window.shuoshuoComment = { loadComment: loadTwikoo }
      : window.loadOtherComment = loadTwikoo
    return
  }

  if ('Twikoo' === 'Twikoo' || !false) {
    if (false) btf.loadComment(document.getElementById('twikoo-wrap'), loadTwikoo)
    else loadTwikoo()
  } else {
    window.loadOtherComment = loadTwikoo
  }
})()</script></div><script src="https://cdn.bootcdn.net/ajax/libs/clipboard.js/2.0.11/clipboard.min.js"></script><script src="/js/floatbox.js"></script><script src="//geoip-js.com/js/apis/geoip2/v2.1/geoip2.js" type="text/javascript"></script><canvas id="universe"></canvas><script defer src="/js/universe.js"></script><script async src="https://npm.elemecdn.com/tzy-blog/lib/js/other/sakura.js"></script><script async src="/js/custom.js"></script><script src="https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js"></script><script async src="/js/rightmenu.js"></script><script id="click-heart" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/click-heart.min.js" async="async" mobile="false"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><!-- hexo injector body_end start --><script data-pjax>
  function butterfly_swiper_injector_config(){
    var parent_div_git = document.getElementById('recent-posts');
    var item_html = '<div class="recent-post-item" style="height: auto;width: 100%"><div class="blog-slider swiper-container-fade swiper-container-horizontal" id="swiper_container"><div class="blog-slider__wrp swiper-wrapper" style="transition-duration: 0ms;"><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" href="pages/主题配置/Hexo 从零开始搭建个人博客 (配置404).html" alt=""><img width="48" height="48" src="/img/loading.gif" data-original="https://api.r10086.com/樱道随机图片api接口.php?图片系列=动漫综合6" alt="" onerror="this.src=https://unpkg.zhimg.com/akilar-candyassets/image/loading.gif; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2025-04-24</span><a class="blog-slider__title" href="pages/主题配置/Hexo 从零开始搭建个人博客 (配置404).html" alt="">Hexo 从零开始搭建个人博客 (配置404)</a><div class="blog-slider__text">再怎么看我也不知道怎么描述它的啦！</div><a class="blog-slider__button" href="pages/主题配置/Hexo 从零开始搭建个人博客 (配置404).html" alt="">详情   </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" href="pages/主题魔改/Hexo.html" alt=""><img width="48" height="48" src="/img/loading.gif" data-original="https://api.r10086.com/樱道随机图片api接口.php?图片系列=动漫综合11" alt="" onerror="this.src=https://unpkg.zhimg.com/akilar-candyassets/image/loading.gif; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2025-05-08</span><a class="blog-slider__title" href="pages/主题魔改/Hexo.html" alt="">Hexo博客实现随机文章功能</a><div class="blog-slider__text">再怎么看我也不知道怎么描述它的啦！</div><a class="blog-slider__button" href="pages/主题魔改/Hexo.html" alt="">详情   </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" href="pages/推荐/Api 接口推荐.html" alt=""><img width="48" height="48" src="/img/loading.gif" data-original="https://cos.tuxiw.cn/blog/bg2.webp" alt="" onerror="this.src=https://unpkg.zhimg.com/akilar-candyassets/image/loading.gif; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2025-05-06</span><a class="blog-slider__title" href="pages/推荐/Api 接口推荐.html" alt="">Api 接口推荐</a><div class="blog-slider__text">再怎么看我也不知道怎么描述它的啦！</div><a class="blog-slider__button" href="pages/推荐/Api 接口推荐.html" alt="">详情   </a></div></div></div><div class="blog-slider__pagination swiper-pagination-clickable swiper-pagination-bullets"></div></div></div>';
    console.log('已挂载butterfly_swiper')
    parent_div_git.insertAdjacentHTML("afterbegin",item_html)
    }
  var elist = 'undefined'.split(',');
  var cpage = location.pathname;
  var epage = 'all';
  var flag = 0;

  for (var i=0;i<elist.length;i++){
    if (cpage.includes(elist[i])){
      flag++;
    }
  }

  if ((epage ==='all')&&(flag == 0)){
    butterfly_swiper_injector_config();
  }
  else if (epage === cpage){
    butterfly_swiper_injector_config();
  }
  </script><script defer src="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiper.min.js"></script><script defer data-pjax src="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiper_init.js"></script><!-- hexo injector body_end end -->
        <style>
            [bg-lazy] {
                background-image: none !important;
                background-color: #eee !important;
            }
        </style>
        <script>
            window.imageLazyLoadSetting = {
                isSPA: false,
                preloadRatio: 1,
                processImages: null,
            };
        </script><script>window.addEventListener("load",function(){var t=/\.(gif|jpg|jpeg|tiff|png)$/i,r=/^data:image\/[a-z\d\-\.\+]+;base64,/;Array.prototype.slice.call(document.querySelectorAll("img[data-original]")).forEach(function(a){var e=a.parentNode;"A"===e.tagName&&(t.test(e.href)||r.test(e.href))&&(e.href=a.dataset.original)})});</script><script>(r=>{r.imageLazyLoadSetting.processImages=t;var a=r.imageLazyLoadSetting.isSPA,o=r.imageLazyLoadSetting.preloadRatio||1,d=i();function i(){var t=Array.prototype.slice.call(document.querySelectorAll("img[data-original]")),e=Array.prototype.slice.call(document.querySelectorAll("[bg-lazy]"));return t.concat(e)}function t(t){(a||t)&&(d=i());for(var e,n=0;n<d.length;n++)0<=(e=(e=d[n]).getBoundingClientRect()).bottom&&0<=e.left&&e.top<=(r.innerHeight*o||document.documentElement.clientHeight*o)&&(()=>{var t,e,a,o,i=d[n];e=function(){d=d.filter(function(t){return i!==t}),r.imageLazyLoadSetting.onImageLoaded&&r.imageLazyLoadSetting.onImageLoaded(i)},(t=i).dataset.loaded||(t.hasAttribute("bg-lazy")?(t.removeAttribute("bg-lazy"),e&&e()):(a=new Image,o=t.getAttribute("data-original"),a.onload=function(){t.src=o,t.removeAttribute("data-original"),t.setAttribute("data-loaded",!0),e&&e()},a.onerror=function(){t.removeAttribute("data-original"),t.setAttribute("data-loaded",!1),t.src=o},t.src!==o&&(a.src=o)))})()}function e(){clearTimeout(t.tId),t.tId=setTimeout(t,500)}t(),document.addEventListener("scroll",e),r.addEventListener("resize",e),r.addEventListener("orientationchange",e)})(this);</script></body></html>